/********************************************************************
	created:	2009/02/26
	created:	26:2:2009   14:44
	filename: 	qy7zPackage.h
	author:		Xiong Jiayu
	copyright:  
	purpose:	
*********************************************************************/
#pragma once

#ifndef __QY7ZPACKAGE_H__
#define __QY7ZPACKAGE_H__

#include "../memsys/qyMap.h"
#include "../memsys/qyString.h"
#include "../memsys/qyArray.h"
#include "qy7zFileFilter.h"

extern "C" 
{
#	include "7zCrc.h"
#	include "7zFile.h"
#	include "7zVersion.h"
#	include "7zCrc.h"
#	include "7zIn.h"
#	include "7zExtract.h"
#	include "7zAlloc.h"
};

/*
===========================================
class qy7zPackage
===========================================
*/
class qy7zPackage
{
public:
	typedef std::vector<qyString>			PathList;
	struct FileItem {
		int fp;
		int size;
		qyString origName;
		unsigned int crc;
	};
	typedef std::map<qyString, FileItem>	FileItemList;

public:
							qy7zPackage();
	virtual					~qy7zPackage();

	bool					SetPackageFile( const qyString &path );
	const qyString &		GetPackageFile( void ) const;

	bool					OpenReadFile( qyFile &file, const qyString &relativePath );

	PathList				GetFileListInPktDir( const qyString &dirIn7z );
	PathList				GetDirListInPktDir( const qyString &dirIn7z );

protected:
	qyString				m_path;
	FileItemList			m_fileItems;

	// 7z stuff
	CFileInStream			m_archiveStream;
	CLookToRead				m_lookStream;
	CSzArEx					m_db;
	ISzAlloc				m_allocImp;
	ISzAlloc				m_allocTempImp;
};

#endif

